

<?php
/*
 * Script file for Sand Dollar Media
 * ===============================================
 * Date: March 17th, 2012
 * Created By: Integration Team
 * ===============================================
 * Criteria:
 
 *  
 */
set_time_limit(3000);
require_once 'config.php';




$result = query("Select distinct country, type
                from cdn.cdnlog2 where country in ('United States', 'Canada')");

                while($row = mysql_fetch_assoc($result))
                {
                    echo $row['country'].Line_Terminator;
                    $query1 = "Select distinct query_date from cdn.cdnlog2";
                    $result1 = query($query1);
                        while ($roww = mysql_fetch_assoc($result1))
                        {
                            $query = "Insert into cdn.cdnlogfinal select country, productid, type, count(1), query_date 
                                from cdn.cdnlog2 where query_date = '".$roww['query_date']."' and type = '".$row['type']."' and country = '".$row['country']."' group by country, productid, type,query_date";
                            
                            query($query);
                            echo "Processed: ".$row['country']." of Type:".$row['type']." for date:".$roww['query_date'].Line_Terminator;
                        }
                }
                

?>

